<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="password" v-model="pwd" @keyup.enter="handleEnter">
    </div>
    <script>
        /* 密码：字母数字，密码长度不小于8位以数字开头 */    
       
        new Vue({
            el:"#app",
            data:{
                pwd:""
            },
            methods: {
            handleEnter(){
                var reg=/^[a-z]+[a-z0-9]{7,}$/i;
                console.log(this.pwd.trim())
                if(!reg.test(this.pwd.trim())){
                    alert("密码不合法，应该以字母开头，包含数字字母,长度不小于8位")
                }
            }
        },
        })
        
    </script>
</body>
</html>